/**
 Copyright (C) 2013 Yuyao Liang

 This source code is release under the BSD License.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.

 Created on Mar 6, 2014 9:38:34 AM
 */
package com.googlecode.exitrule.ui;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;

import net.sourceforge.jdatepicker.impl.JDatePanelImpl;
import net.sourceforge.jdatepicker.impl.JDatePickerImpl;
import net.sourceforge.jdatepicker.impl.UtilCalendarModel;
import net.sourceforge.jdatepicker.impl.UtilDateModel;

import java.awt.Insets;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.border.BevelBorder;

/**
 * @author lianyuy
 * 
 */
public class StockBroughtInformationPanel extends JPanel {

	private static final long serialVersionUID = -6884873482027059595L;
	private JTextField stockNameField;
	private JDatePickerImpl purchaseDateField;
	private JTextField purchasePriceField;

	/**
	 * Create the panel.
	 */
	public StockBroughtInformationPanel() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
		gridBagLayout.rowHeights = new int[] { 0, 20, 0, 0, 0 };
		gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
		gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0,
				Double.MIN_VALUE };
		setLayout(gridBagLayout);

		JLabel lblStockname = new JLabel("StockName");
		GridBagConstraints gbc_lblStockname = new GridBagConstraints();
		gbc_lblStockname.insets = new Insets(0, 0, 5, 5);
		gbc_lblStockname.anchor = GridBagConstraints.WEST;
		gbc_lblStockname.gridx = 0;
		gbc_lblStockname.gridy = 0;
		add(lblStockname, gbc_lblStockname);

		stockNameField = new JTextField();
		GridBagConstraints gbc_stockNameField = new GridBagConstraints();
		gbc_stockNameField.insets = new Insets(0, 0, 5, 0);
		gbc_stockNameField.fill = GridBagConstraints.HORIZONTAL;
		gbc_stockNameField.gridx = 1;
		gbc_stockNameField.gridy = 0;
		add(stockNameField, gbc_stockNameField);
		stockNameField.setColumns(10);

		JLabel lblPurchaseDate = new JLabel("Purchase Date");
		GridBagConstraints gbc_lblPurchaseDate = new GridBagConstraints();
		gbc_lblPurchaseDate.anchor = GridBagConstraints.WEST;
		gbc_lblPurchaseDate.insets = new Insets(0, 0, 5, 5);
		gbc_lblPurchaseDate.gridx = 0;
		gbc_lblPurchaseDate.gridy = 1;
		add(lblPurchaseDate, gbc_lblPurchaseDate);

		purchaseDateField = new JDatePickerImpl(new JDatePanelImpl(
				new UtilCalendarModel()));
		purchaseDateField.setShowYearButtons(true);
		GridBagConstraints gbc_purchaseDateField = new GridBagConstraints();
		gbc_purchaseDateField.insets = new Insets(0, 0, 5, 0);
		gbc_purchaseDateField.fill = GridBagConstraints.BOTH;
		gbc_purchaseDateField.gridx = 1;
		gbc_purchaseDateField.gridy = 1;
		add(purchaseDateField, gbc_purchaseDateField);

		JLabel lblPurchasePrice = new JLabel("Purchase Price");
		GridBagConstraints gbc_lblPurchasePrice = new GridBagConstraints();
		gbc_lblPurchasePrice.anchor = GridBagConstraints.EAST;
		gbc_lblPurchasePrice.insets = new Insets(0, 0, 5, 5);
		gbc_lblPurchasePrice.gridx = 0;
		gbc_lblPurchasePrice.gridy = 2;
		add(lblPurchasePrice, gbc_lblPurchasePrice);

		purchasePriceField = new JTextField();
		GridBagConstraints gbc_purchasePriceField = new GridBagConstraints();
		gbc_purchasePriceField.insets = new Insets(0, 0, 5, 0);
		gbc_purchasePriceField.fill = GridBagConstraints.HORIZONTAL;
		gbc_purchasePriceField.gridx = 1;
		gbc_purchasePriceField.gridy = 2;
		add(purchasePriceField, gbc_purchasePriceField);
		purchasePriceField.setColumns(10);

		JButton btnNewButton = new JButton("OK");
		GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.gridwidth = 2;
		gbc_btnNewButton.gridx = 0;
		gbc_btnNewButton.gridy = 3;
		add(btnNewButton, gbc_btnNewButton);
	}

	public String getStockName() {
		return stockNameField.getText();
	}

	public String getPurchaseDate() {
		return purchaseDateField.getJFormattedTextField().getText();
	}

	public String getPurchasePrice() {
		return purchasePriceField.getText();
	}
}
